package com.goldsprite.gameframeworks.rhino;
import com.goldsprite.gameframeworks.log.*;

public class CoreTestRhino {
	public static void test3() {
		Debug.log("开始执行js脚本...");
		String resultStr = JsEngine.eval(
//			"var ctx = com.goldsprite.microhorigame.android.AndroidGdxLauncher.getCtx();" +
//			"var ecs = com.goldsprite.gameframeworks.ecs;" +
//			"var Gobject = ecs.entity.GObject;" +
//			"var player = ecs.system.GameSystem.sceneSystem.findGObjectByTag(\"Player\");" +
//			"var playerName = player.getName();" +
//			"var playerPos = player.getTransform().getPosition();" +
//			"var msg = \"成功找到玩家(\"+playerName+\")的位置: \"+playerPos;"+
//			"//ctx.runOnUiThread(new java.lang.Runnable(){public void run(){" +
//			"//   android.widget.Toast.makeText(ctx, msg, 0).show();" +
//			"//}});" +
//			"//com.goldsprite.gameframeworks.log.Debug.log(msg);"+
//			"//\"eval js finished.\";"
//			"\n var ctx = com.goldsprite.microhorigame.android.AndroidGdxLauncher.getCtx();" +
			"\n var ecs = com.goldsprite.gameframeworks.ecs;" +
			"\n var player = ecs.system.GameSystem.sceneSystem.findGObjectByTag('Player');" +
			"\n var playerName = player.getName();" +
			"\n var playerPos = player.getTransform().getPosition();" +
			"\n var msg = '成功找到玩家('+playerName+'), 位置: '+playerPos;"+
			"\n com.goldsprite.gameframeworks.log.Debug.log('JsEngine', msg);"+
			//Runnable不知为何不可用
//			"\n var runnable = new Runnable(){public void run(){ com.goldsprite.gameframeworks.log.Debug.log(msg); }};"+
//			"\n runnable.run();"+
			"\n '脚本执行成功.';"+
			""
		);
		Debug.log(resultStr);
	}
}
